package cn.com.demo.tp07.service.Impl;

import cn.com.demo.tp07.service.TestService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.ribbon.proxy.annotation.Hystrix;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Random;
@Service
public class TestServiceImpl implements TestService {

    private Random random;
    @Override
    @HystrixCommand(fallbackMethod = "rr")
    public int getMath() {
      int i=  10;
        System.out.println(i);
      if (i<3){
          throw new RuntimeException();
      }else
      {
          return i;
      }

    }

    public int rr(){
        return -1;
    }

}
